<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('服务商基本信息')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: cropbox-css" />
</head>
<body>
<div class="main-content" >
    <div class="tabs-left">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#tab-8">服务商信息</a>
            </li>
            <li  class="" ><a data-toggle="tab" href="#tab-9"  onclick="merclick()">服务商资质</a>
            </li>
        </ul>
        <div class="tab-content ">
            <div id="tab-8" class="tab-pane active">
                <div class="panel-body">
                    <fieldset id="f">
                        <input type="hidden" id="agentNum" th:value="${agentInfo.agentNum}">
                        <input type="hidden" id="status" th:value="${agentInfo.status}">
                        <input type="hidden" id="agentStatus" th:value="${agentInfo.agentStatus}">

                        <form id="form-agent-add" class="form-horizontal">
                            <h4 class="form-header h4">基本信息</h4>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">服务商名称：</label>
                                        <div class="col-sm-8">
                                            <input name="agentName" th:value="${agentInfo.agentName}" class="form-control"  type="text" maxlength="30"  required>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">统一社会信用代码:</label>
                                        <div class="col-sm-8">
                                            <input name="organCode" th:value="${agentInfo.organCode}" placeholder="" class="form-control"  type="text" maxlength="30"  required>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">服务商地区：</label>
                                        <div class="col-sm-2" style="width: 120px;">
                                            <select id="province" name="province"  onchange="javascript:window.province('p')" class="province form-control m-b" >
                                                <option th:each="p:${pList}" th:text="${p.areaName}" th:value="${p.areaCode}"  th:selected="${p.areaCode} eq ${agentInfo.province}"></option>
                                            </select>
                                        </div>
                                        <div class="col-sm-2" style="width: 120px;">
                                            <select id="city" name="city" onchange="javascript:window.province('c')" class="city form-control m-b" >
                                                <option th:each="c:${cList}" th:text="${c.areaName}" th:value="${c.areaCode}" th:selected="${c.areaCode} eq ${agentInfo.city}"></option>
                                            </select>
                                        </div>
                                        <div class="col-sm-2" style="width: 120px;">
                                            <select id="area" name="area" onchange="javascript:window.province('a')" class="area form-control m-b" >
                                                <option th:each="a:${aList}" th:text="${a.areaName}" th:value="${a.areaCode}" th:selected="${a.areaCode} eq ${agentInfo.area}"></option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">详细地址：</label>
                                        <div class="col-sm-8">
                                            <input name="agentArea" th:value="${agentInfo.agentArea}" placeholder="" class="form-control"  type="text" maxlength="30"  required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">法人名称：</label>
                                        <div class="col-sm-8">
                                            <input name="commissary" th:value="${agentInfo.commissary}" placeholder="" class="form-control"  type="text" maxlength="30"  required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">法人身份证号码：</label>
                                        <div class="col-sm-8">
                                            <input name="identityNum"  th:value="${agentInfo.showIdentitynum}" placeholder="" class="form-control"  type="text"     required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">联系人姓名：</label>
                                        <div class="col-sm-8">
                                            <input name="linkMan" th:value="${agentInfo.linkMan}"  placeholder="" class="form-control"  type="text" maxlength="30" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">手机号码：</label>
                                        <div class="col-sm-8">
                                            <input name="linkPhone" th:value="${agentInfo.linkPhone}" minlength="11" maxlength="11" placeholder="" class="form-control"  type="text"   required>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">

                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">联系人邮箱：</label>
                                        <div class="col-sm-8">
                                            <input name="linkEmail" th:value="${agentInfo.linkEmail}" placeholder="" class="form-control"  type="text" maxlength="30"  required>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <h4 class="form-header h4" >账户信息</h4>
                            <div class="row">
                                <div class="col-sm-6" th:if="${agentInfo.status == '1'}">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">账户类型：</label>
                                        <div class="col-sm-8">
                                            <select id="nature" name="nature" class="form-control m-b" th:with="type=${@dict.getType('zd_nature')}">
                                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictValue} eq ${accounts.nature}"></option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">开户银行账户：</label>
                                        <div class="col-sm-8">
                                            <input name="showScreennum" th:value="${accounts!= null?accounts.showScreennum:''}" minlength="16"  maxlength="19" placeholder="" class="form-control"  type="text"   required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6" id="card">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">结算人身份证号：</label>
                                        <div class="col-sm-8">
                                            <input name="showScreenidnum" th:value="${accounts!= null?accounts.showScreenidnum:''}" placeholder=""  class="form-control"  type="text"   required>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">预留手机号：</label>
                                        <div class="col-sm-8">
                                            <input name="showResphone"  th:value="${accounts!= null?accounts.showResphone:''}" minlength="11" maxlength="11" placeholder="" class="form-control"  type="text"   required>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">总行名称：</label>
                                        <div class="col-sm-8">
                                            <input name="bankHeadname" th:value="${accounts!= null?accounts.bankHeadname:''}"  id="selectZh" readonly="readonly"  onclick="openZh()" placeholder="点击选择总行" class="form-control"  type="text" maxlength="30"/>
                                            <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">支行名称：</label>
                                        <div class="col-sm-8">
                                            <input name="bankName" th:value="${accounts!= null?accounts.bankName:''}" id="branch_bank" onclick="openZhihang()" readonly="readonly" placeholder="点击选择支行" class="form-control"  type="text" maxlength="30"  required>
                                            <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">账户开户地：</label>
                                        <div class="col-sm-2" style="width: 120px;">
                                            <select id="province1" name="province1" onchange="javascript:window.province1('p')" class="province form-control m-b" >
                                                <option th:each="p1:${pList}" th:text="${p1.areaName}" th:value="${p1.areaCode}"  th:selected="${p1.areaCode} eq ${province1}"></option>
                                            </select>
                                        </div>
                                        <div class="col-sm-2" style="width: 120px;">
                                            <select id="city1" name="city1" onchange="javascript:window.province1('c')" class="city form-control m-b" >
                                                <option th:each="c1:${cList}" th:text="${c1.areaName}" th:value="${c1.areaCode}"  th:selected="${c1.areaCode} eq ${city1}"></option>
                                            </select>
                                        </div>
                                        <div class="col-sm-2" style="width: 140px;">
                                            <select id="area1" name="area1" onchange="javascript:window.province1('a')" class="area form-control m-b">
                                                <option th:each="a1:${aList}" th:text="${a1.areaName}" th:value="${a1.areaCode}"  th:selected="${a1.areaCode} eq ${area1}"></option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">支付系统行号：</label>
                                        <div class="col-sm-8">
                                            <input name="bankNum" th:value="${accounts!= null?accounts.bankNum:''}" placeholder="" class="form-control"  type="text" maxlength="30"  required>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div th:if="${(agentInfo.agentNature+'') == '1' && (agentInfo.specialGradeId+'' != null || agentInfo.specialGradeId+'' != '' || agentInfo.specialGradeId+'' != 'null')}">
                            <h4 class="form-header h4">盟主引流奖励</h4>
                            <div class="row" >
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">首次购机(台)：</label>
                                        <div class="col-sm-8">
                                            <input type="text"   name="numbers" th:value="${specialBounty == null ? '':specialBounty.numbers}"  readonly="readonly"  placeholder="首次购机台数" class="form-control"   maxlength="10"  >
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">引流奖励：</label>
                                        <div class="col-sm-8">
                                            <input type="text"   name="sumMoney" th:value="${specialBounty == null ? '':specialBounty.sumMoney}"    readonly="readonly"  placeholder="引流奖励" class="form-control"   maxlength="10"  >
                                        </div>
                                    </div>
                                </div>
                            </div>
                            </div>
                            <h4 class="form-header h4">其他信息</h4>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">销售经理：</label>
                                        <div class="col-sm-8">
                                            <input type="text"   name="sm_name2" th:value="${agentInfo.smName == null ? '':agentInfo.smName}" id="sm_name2" readonly="readonly" onclick="openXs('xs')" placeholder="点击选择销售经理" class="form-control"   maxlength="30"  >
                                            <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                                            <input type="hidden" name="sm_num2" id="sm_num2" >
                                        </div>
                                        <!--/salesman/salesman-->
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">运营经理：</label>
                                        <div class="col-sm-8">
                                            <input type="text"   th:value="${agentInfo.smName1 == null ? '':agentInfo.smName1}" name="sm_name1"  id="sm_name1" readonly="readonly" onclick="openYy('yy')" placeholder="点击选择运营经理" class="form-control"   maxlength="30"  >
                                            <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                                            <input type="hidden" name="sm_num1" id="sm_num1">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label is-required">有效期：</label>
                                        <div class="input-daterange input-group" >
                                            <input   name="beginValid"  th:value="${agentInfo.beginValid}" style="margin-left: 14px;width: 170px;" type="text" class="input-sm form-control" id="laydate-startTime" placeholder="起始日期"/>
                                            <span style="margin-right: 5px;" class="input-group-addon">-</span>
                                            <input   name="endValid"  th:value="${agentInfo.endValid}" style="width: 150px;" type="text" class="input-sm form-control" id="laydate-endTime" placeholder="结束日期"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </fieldset>
                </div>
            </div>
            <div id="tab-9" class="tab-pane">
                <div class="panel-body">
                    <div class="ibox-title">
                        <ul id="content">
                        </ul>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</div>

</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: utils-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">

    //服务商资质
    function merclick() {
        var agentNum = $("#agentNum").val();
        $.post(ctx + "agentInfo/agentInfo/getImg", {'agentNum': agentNum}, function (data) {
            var html = '';
            data.rows.forEach(function(value){
                html += "<h3 style='margin-right: -18px;'>" + name(value.type)+"</h3>";
                html +='<li><img width="500px;" height="400px;" data-original=' + value.fileid + ' src =' + value.fileid + '></li>';
                html += "<br><br>";
            });
            $("#content").append(html);
            var viewer = new Viewer(document.getElementById('content'), {
                url: 'data-original'
            });
        })

    }


    $(function(){
        <!-- laydate示例 -->
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            var startDate = laydate.render({
                elem: '#laydate-startTime',
                max: $('#laydate-endTime').val(),
                theme: 'molv',
                trigger: 'click',
                done: function(value, date) {
                    // 结束时间大于开始时间
                    if (value !== '') {
                        endDate.config.min.year = date.year;
                        endDate.config.min.month = date.month - 1;
                        endDate.config.min.date = date.date;
                    } else {
                        endDate.config.min.year = '';
                        endDate.config.min.month = '';
                        endDate.config.min.date = '';
                    }
                }
            });

            var endDate = laydate.render({
                elem: '#laydate-endTime',
                min: $('#laydate-startTime').val(),
                theme: 'molv',
                trigger: 'click',
                done: function(value, date) {
                    // 开始时间小于结束时间
                    if (value !== '') {
                        startDate.config.max.year = date.year;
                        startDate.config.max.month = date.month - 1;
                        startDate.config.max.date = date.date;
                    } else {
                        startDate.config.max.year = '';
                        startDate.config.max.month = '';
                        startDate.config.max.date = '';
                    }
                }
            });
        });
    });

    var url = ctx + "/agentInfo/agentInfo";
    function submitHandler() {
        /*if (isClick == true){
            return;
        }
        if ($.validate.form()) {
            var form = $.form.getField($("#form-agent-add").serializeArray());
            $.operate.save(url + "/add", form);

        }*/
    }


    /**
     * 总行
     */
    function openZh(){
        $.modal.open("选择总行", ctx + "agentInfo/agentInfo/selectZh","1100","500");
    }

    /**
     * 销售
     */
    function openXs(obj){
        $.modal.open("选择销售经理", ctx + "agentInfo/agentInfo/jl?obj=" + obj,"1100","500");
    }

    /**
     * 运营经理
     */
    function openYy(obj){
        $.modal.open("选择运营经理", ctx + "agentInfo/agentInfo/jl?obj=" + obj,"1100","500");
    }

    /**
     * 运营支行
     */
    function openZhihang(){
        if($("#selectZh").val().length == 0){
            layer.msg('请先选择总行',{icon: 2,time:1000});
            return;
        }
        $.modal.open("选择支行", ctx + "agentInfo/agentInfo/zhihang?head_bank="+$("#selectZh").val(),"1100","500");
    }






    /**
     *
     * @param type 传入 省 p 市 c 区 a
     */
    function province(type) {
        var url = ctx + "area/area/list"; //获取地址信息
        if (type == 'p'){  //联动市
            if($("#province").find("option:selected").val() == ''){
                defaultOption("city","请选择市");
                defaultOption("area","请选择区");
            } else {
                $.post(url,{'parentId':$("#province").val()},function(result){
                    if (result.code == '0'){
                        initSelect("city",result);
                    }
                });
            }
        } else if (type == 'c'){  //联动县
            $.post(url,{'parentId':$("#city").val()},function(result){
                if (result.code == '0',result){
                    initSelect("area",result);
                }
            });
        }
    }

    /**
     *
     * @param type 传入 省 p 市 c 区 a
     */
    function province1(type) {
        var url = ctx + "area/area/list"; //获取地址信息
        if (type == 'p'){  //联动市
            if($("#province1").find("option:selected").val() == ''){
                defaultOption("city1","请选择市");
                defaultOption("area1","请选择区");
            } else {
                $.post(url,{'parentId':$("#province1").val()},function(result){
                    if (result.code == '0'){
                        initSelect("city1",result);
                    }
                });
            }
        } else if (type == 'c'){  //联动县
            $.post(url,{'parentId':$("#city1").val()},function(result){
                if (result.code == '0',result){
                    initSelect("area1",result);
                }
            });
        }
    }

    //初始化 select选项
    function initSelect(selectId,data) {
        //清空旧的数据
        if (selectId != 'province'){
            $("#"+selectId).empty();
        } else if (selectId != 'province1'){
            $("#"+selectId).empty();
        }
        var option = '';
        data.rows.forEach(function(value){
            option += "<option value='"+value.areaCode+"'>"+value.areaName+"</option>";
        });
        $("#"+selectId).append(option);
    }

    //初始化 select选项
    function defaultOption(selectId,text) {
        $("#"+selectId).empty();
        $("#"+selectId).append("<option value=''>" + text +"</option>");
    }


    var noClick = function () {
        $('#f').attr("disabled","disabled");
        $('#f').css("-ms-pointer-events","none");
        $('#f').css("pointer-events","none");
    }();


    function name(value) {
        var msg = '';
        if (value == '1'){
            msg = '身份证正面';
        } else if (value == '2'){
            msg = '身份证反面';
        }else if (value == '5'){
            msg = '营业执照';
        }else if (value == '16'){
            msg = '开户许可证';
        }else if (value == '7'){
            msg = '门头照外景';
        }else if (value == '6'){
            msg = '门头照内景';
        }else if (value == '17'){
            msg = '服务商情况说明表';
        }else if (value == '14'){
            msg = '税务登记证';
        }else if (value == '15'){
            msg = '组织机构代码证';
        }else if (value == '45'){
            msg = '盟主申请凭证';
        }
        return msg;
    }


    /**
     * app数据
     */
   /* var  app = function () {
        if ($("#status").val() == '0' && $("#agentStatus").val() == '1'){
            $("#isShow").hide();
        } else {
            $("#isShow").show();
        }
    }();*/

    /**
     * 初始化对公对私类型隐藏展示
     * */
    var  changeAccountType = function () {
        var nature = $("#nature").find("option:selected").val();
        //对公
        if (nature == '1'){
            $("#card").hide();
            //对私
        } else if (nature == '2'){
            $("#card").show();
        }
    }();


</script>
</body>
</html>